package game;

import javax.swing.JOptionPane;

public class Tax extends Field {
	private int taxAmount;
	private int taxRate = -1;

	//Konstruktør
	public Tax(String name, int taxAmount){
		setName(name);
		this.taxAmount = taxAmount;
		this.taxRate = 10;
	}
	
	//spiller lander på Tax
	public void landOnField(Player player){
		
		//spiller lander på Caravan
		if(getName()=="Caravan"){
			
			Object[] posibleChoices = {"Betal 4000","Betal 10% af formue"};
			int valg = JOptionPane.showOptionDialog(null, "Du er landet på Caravan.\nBetal 10% af din pengebeholdning eller betal 4000\n", "Caravan", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, posibleChoices, posibleChoices[0]);
			
			//Betaler 4000
			if(valg==0){
				player.getAccount().addPoints(-taxAmount);
			}
			
			//ellers kan spiller vælge at betale 10% af pengebeholdning
			else{
				player.getAccount().addPoints(-((taxRate*(player.getAccount().getPoint())/100)));
			}
		}
		
		//spiller lander på Goldmine
		else{
			player.getAccount().addPoints(-taxAmount);
		}
		
	}

}

